﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.ruleinfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BLL.ruletype bll = new BLL.ruletype();
                DataSet ds = bll.GetAllList();
                ddltype.DataSource = ds.Tables[0];
                ddltype.DataTextField = "rtname";
                ddltype.DataValueField = "rtid";
                ddltype.DataBind();
            }

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtrname.Text.Trim().Length == 0)
            {
                strErr += "rname不能为空！\\n";
            }
            if (!PageValidate.IsNumberSign(txtrnum.Text))
            {
                strErr += "rnum格式错误！\\n";
            }
            if (!PageValidate.IsNumberSign(txtwnum.Text))
            {
                strErr += "wnum格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int rtid = int.Parse(this.ddltype.SelectedValue.ToString());
            string rname = this.txtrname.Text;
            int rnum = int.Parse(this.txtrnum.Text);
            int wnum = int.Parse(this.txtwnum.Text);
            bool ischecked = this.chkischecked.Checked;

            lcs.Model.ruleinfo model = new lcs.Model.ruleinfo();
            model.rtid = rtid;
            model.rname = rname;
            model.rnum = rnum;
            model.wnum = wnum;
            model.ischecked = ischecked;

            lcs.BLL.ruleinfo bll = new lcs.BLL.ruleinfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "List.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
